package com.wanmait.wanmarecruit.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wanmait.wanmarecruit.service.PositionTypeService;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.wanmait.wanmarecruit.entity.PositionType;
import com.wanmait.wanmarecruit.mapper.PositionTypeMapper;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional(rollbackFor = Exception.class)
public class PositionTypeServiceImpl extends ServiceImpl<PositionTypeMapper, PositionType> implements PositionTypeService {

    @Resource
    private  PositionTypeMapper positionTypeMapper;

    @Override
    public List<PositionType> getAllPositionType() {
        LambdaQueryWrapper<PositionType> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.select(PositionType::getTypeName,PositionType::getId);
        queryWrapper.orderByAsc(PositionType::getSort);
        return this.list(queryWrapper);
    }

    @Override
    public PageInfo<PositionType> indexSixPositionType() {
        PageHelper.startPage(1,6);
        LambdaQueryWrapper<PositionType> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        lambdaQueryWrapper.orderByAsc(PositionType::getSort);
        return new PageInfo<>(positionTypeMapper.selectList(lambdaQueryWrapper));
    }
}
